/*
 * @Description: 防抖函数
 * @version: 
 * @Author: 171
 * @Date: 2022-09-12 18:20:11
 * @LastEditors: 171
 * @LastEditTime: 2022-09-12 18:20:14
 */
export const useThrottle = (fn: Function, delay: number, immediate = false) => { // 节流函数，限制scroll触发频率
  let timer: null | NodeJS.Timeout = null;
  return function(...args: any[]) {
    if(timer) return;
    timer = setTimeout(function() {
      fn(...args);
      timer = null;
    }, delay);
  }
}